package thread;

public class SleepDemo2 {
    public static void main(String[] args) {
        Thread lin = new Thread("林一一") {
            public void run() {
                System.out.println(getName() + "哈哈哈");
                try {
                    Thread.sleep(100000000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(getName() + "突然出现");
            }
        };
        Thread zhang = new Thread("张二二") {
            public void run() {
                System.out.println(getName() + "启动");
                for (int i = 0; i < 5; ++i) {
                    System.out.println(getName() + "  线程2: " + i);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }

                System.out.println(getName() + "我是张二二");
                lin.interrupt();//中断lin的睡眠阻塞
            }
        };
        lin.start();
        zhang.start();
    }
}
